

import java.util.Scanner;


/**
 * This program calculates the gravitational force between two bodies in ounces.
 * It prompts the user for two weight inputs in pounds and the distance between
 * them in feet, converting those values to kilograms and meters respectively.
 * It then enters them into Newton's Law of Gravity (F = G * m1 * m2 / (d * d))
 * and displays the resultant force in ounces (as opposed to the value in newtons
 * initially produced by this equation).
 * 
 * @author Tara Gallagher
 *
 */
public class HW1 {

	private static Scanner input;

	public static void main(String[] args) {
		
		// Read inputs for weights of two bodies in pounds.
		double weight1;
		double weight2;
		input = new Scanner(System.in);
		System.out.print("Enter weight1 in pounds: ");
		weight1 = input.nextDouble();
		System.out.print("Enter weight2 in pounds: ");
		weight2 = input.nextDouble();

		// Convert pounds to kilograms.
		final double constantPoundsToKilograms = .45359;
		weight1 *= (constantPoundsToKilograms);
		weight2 *= (constantPoundsToKilograms);

		// Read input for distance between bodies.
		double distance;
		System.out.print("Enter the distance separating them in feet: ");
		distance = input.nextDouble();

		// Convert distance from feet to meters.
		final double constantFeetToMeters = .3048;
		distance *= (constantFeetToMeters);

		// Calculate gravitational force in newtons.
		final double gravitationalConstant = 6.67384e-11;
		double gravitationalForce;
		gravitationalForce = gravitationalConstant * weight1 * weight2 / (distance * distance);

		// Convert gravitational force from newtons to ounces.
		final double constantNewtonsToOunces = 3.5969;
		gravitationalForce *= (constantNewtonsToOunces);

		System.out.printf("The gravitatational force is %e ounces.", gravitationalForce);
	}

}

